{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from safetensors import safe_open\n",
    "\n",
    "tensors = {}\n",
    "path = '/home/lyc/TNTprojectz/KE/EasyEdit/knb_edit/checkpoint/counterfact/80_KNB_counterfact_all_Llama-2-7b-hf_max_99.85_80_down_proj/adapter_model.safetensors'\n",
    "with safe_open(path, framework=\"pt\", device=0) as f:\n",
    "    for k in f.keys():\n",
    "        tensors[k] = f.get_tensor(k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "base_model.model.model.layers.0.mlp.down_proj.knb_W.weight torch.Size([4096, 3]) torch.float32\n",
      "base_model.model.model.layers.1.mlp.down_proj.knb_W.weight torch.Size([4096, 9]) torch.float32\n",
      "base_model.model.model.layers.10.mlp.down_proj.knb_W.weight torch.Size([4096, 2]) torch.float32\n",
      "base_model.model.model.layers.11.mlp.down_proj.knb_W.weight torch.Size([4096, 5]) torch.float32\n",
      "base_model.model.model.layers.12.mlp.down_proj.knb_W.weight torch.Size([4096, 3]) torch.float32\n",
      "base_model.model.model.layers.13.mlp.down_proj.knb_W.weight torch.Size([4096, 12]) torch.float32\n",
      "base_model.model.model.layers.14.mlp.down_proj.knb_W.weight torch.Size([4096, 9]) torch.float32\n",
      "base_model.model.model.layers.15.mlp.down_proj.knb_W.weight torch.Size([4096, 23]) torch.float32\n",
      "base_model.model.model.layers.16.mlp.down_proj.knb_W.weight torch.Size([4096, 24]) torch.float32\n",
      "base_model.model.model.layers.17.mlp.down_proj.knb_W.weight torch.Size([4096, 23]) torch.float32\n",
      "base_model.model.model.layers.18.mlp.down_proj.knb_W.weight torch.Size([4096, 11]) torch.float32\n",
      "base_model.model.model.layers.19.mlp.down_proj.knb_W.weight torch.Size([4096, 8]) torch.float32\n",
      "base_model.model.model.layers.2.mlp.down_proj.knb_W.weight torch.Size([4096, 3]) torch.float32\n",
      "base_model.model.model.layers.20.mlp.down_proj.knb_W.weight torch.Size([4096, 11]) torch.float32\n",
      "base_model.model.model.layers.21.mlp.down_proj.knb_W.weight torch.Size([4096, 4]) torch.float32\n",
      "base_model.model.model.layers.22.mlp.down_proj.knb_W.weight torch.Size([4096, 5]) torch.float32\n",
      "base_model.model.model.layers.23.mlp.down_proj.knb_W.weight torch.Size([4096, 5]) torch.float32\n",
      "base_model.model.model.layers.24.mlp.down_proj.knb_W.weight torch.Size([4096, 6]) torch.float32\n",
      "base_model.model.model.layers.25.mlp.down_proj.knb_W.weight torch.Size([4096, 13]) torch.float32\n",
      "base_model.model.model.layers.26.mlp.down_proj.knb_W.weight torch.Size([4096, 11]) torch.float32\n",
      "base_model.model.model.layers.27.mlp.down_proj.knb_W.weight torch.Size([4096, 17]) torch.float32\n",
      "base_model.model.model.layers.28.mlp.down_proj.knb_W.weight torch.Size([4096, 18]) torch.float32\n",
      "base_model.model.model.layers.29.mlp.down_proj.knb_W.weight torch.Size([4096, 17]) torch.float32\n",
      "base_model.model.model.layers.3.mlp.down_proj.knb_W.weight torch.Size([4096, 3]) torch.float32\n",
      "base_model.model.model.layers.30.mlp.down_proj.knb_W.weight torch.Size([4096, 58]) torch.float32\n",
      "base_model.model.model.layers.31.mlp.down_proj.knb_W.weight torch.Size([4096, 179]) torch.float32\n",
      "base_model.model.model.layers.4.mlp.down_proj.knb_W.weight torch.Size([4096, 12]) torch.float32\n",
      "base_model.model.model.layers.5.mlp.down_proj.knb_W.weight torch.Size([4096, 6]) torch.float32\n",
      "base_model.model.model.layers.6.mlp.down_proj.knb_W.weight torch.Size([4096, 4]) torch.float32\n",
      "base_model.model.model.layers.7.mlp.down_proj.knb_W.weight torch.Size([4096, 10]) torch.float32\n",
      "base_model.model.model.layers.8.mlp.down_proj.knb_W.weight torch.Size([4096, 10]) torch.float32\n",
      "base_model.model.model.layers.9.mlp.down_proj.knb_W.weight torch.Size([4096, 5]) torch.float32\n"
     ]
    }
   ],
   "source": [
    "for k, v in tensors.items():\n",
    "    print(k, v.shape, v.dtype)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "ke2torch23cu121",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
